// Fill out your copyright notice in the Description page of Project Settings.


#include "UI/TUGameDataWidget.h"
#include "TUGameModeBase.h"
#include "Player/TUPlayerState.h"

int32 UTUGameDataWidget::GetKillsNum() const
{
    auto PlayerState = GetTUPlayerState();
    return PlayerState->GetKillsNum();
}

int32 UTUGameDataWidget::GetCurrentRoundNum() const
{
    const auto GameMode = GetTUGameMode();
    return GameMode ? GameMode->GetCurrentRoundNum() : 0;
}

int32 UTUGameDataWidget::GetTotalRoundsNum() const
{
    const auto GameMode = GetTUGameMode();
    return GameMode ? GameMode->GetGameData().RoundsNum : 0;
}

int32 UTUGameDataWidget::GetRoundSecondsRemaining() const
{
    const auto GameMode = GetTUGameMode();
    return GameMode ? GameMode->GetRoundSecondsRemaining() : 0;
}

ATUGameModeBase* UTUGameDataWidget::GetTUGameMode() const
{
    return GetWorld() ? Cast<ATUGameModeBase>(GetWorld()->GetAuthGameMode()) : nullptr;
}

ATUPlayerState* UTUGameDataWidget::GetTUPlayerState() const
{
    return GetOwningPlayer() ? Cast<ATUPlayerState>(GetOwningPlayer()->PlayerState) : nullptr;
}
